home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / AGADemo / AGADemo Sources / LPPobView.cp < prev    next >
Encoding:
Text File  |  1995-08-27  |  3.9 KB  |  143 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //        • LPPobView.cp                © 1995, Éric Forget. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    ************************************************************************
  6. //    *                                                                      *
  7. //    *    Before using this code you should read the "License Agreement"     *
  8. //    *    document and agree with it.                                        *
  9. //    *                                                                      *
  10. //    ************************************************************************
  11. //
  12. //    LPPobView is a class that will load a PPob resource and put the
  13. //    superview of this hierarchy as a subview of the LPPobView's superview.
  14. //
  15. //    It is useful when you want to have a few view that are superposed as
  16. //    in preferences panels.
  17. //
  18. // ---------------------------------------------------------------------------
  19. //
  20. //    Instruction Notes:
  21. //    -----------------
  22. //
  23. //    1) Write a PPob resource with Constructor (or whatever you want!) which is
  24. //       a View;
  25. //
  26. //    2) In the class you want to insert the View, insert a LPPobView;
  27. //
  28. //    3) At the beginning of your application, add the call:
  29. //
  30. //        URegistrar::RegisterClass(LPPobView::class_ID, LPPobView::CreatePPobViewStream);
  31. //
  32. //    4) In your application you can use the inserted view as if is was
  33. //       created inside the Window or the dialog in the first time.
  34. //
  35. // ---------------------------------------------------------------------------
  36.  
  37. #include    "LPPobView.h"
  38.  
  39.  
  40.  
  41. // ---------------------------------------------------------------------------
  42. //        • CreatePPobViewStream [static]
  43. // ---------------------------------------------------------------------------
  44. //    Return a new PPobView object initialized using data from a Stream
  45.  
  46. LPPobView*
  47. LPPobView::CreatePPobViewStream(
  48.     LStream    *inStream)
  49. {
  50.     return (new LPPobView(inStream));
  51. }
  52.  
  53.  
  54. // ---------------------------------------------------------------------------
  55. //        • LPPobView()
  56. // ---------------------------------------------------------------------------
  57. //    Default Constructor
  58.  
  59. LPPobView::LPPobView()
  60. {
  61.     InitPPobView(-1);
  62. }
  63.  
  64.  
  65. // ---------------------------------------------------------------------------
  66. //        • LPPobView(const LPPobView&)
  67. // ---------------------------------------------------------------------------
  68. //    Copy Constructor
  69. //
  70. //    Does shallow copy; SubPanes are not copied.
  71.  
  72. LPPobView::LPPobView(
  73.     const LPPobView    &inOriginal)
  74.         : LView(inOriginal)
  75. {
  76.     InitPPobView(inOriginal.mViewID);
  77. }
  78.  
  79.  
  80. // ---------------------------------------------------------------------------
  81. //        • LPPobView(SPaneInfo&, SViewInfo&)
  82. // ---------------------------------------------------------------------------
  83. //    Construct View from input parameters
  84.  
  85. LPPobView::LPPobView(
  86.     const SPaneInfo    &inPaneInfo,
  87.     const SViewInfo &inViewInfo,
  88.     const ResIDT    inViewID)
  89.         : LView(inPaneInfo, inViewInfo)
  90. {
  91.     InitPPobView(inViewID);
  92. }
  93.  
  94.  
  95. // ---------------------------------------------------------------------------
  96. //        • LPPobView(LStream*)
  97. // ---------------------------------------------------------------------------
  98. //    Construct View from data in a Stream
  99.  
  100. LPPobView::LPPobView(
  101.     LStream    *inStream)
  102.         : LView(inStream)
  103. {
  104.     ResIDT        viewID;
  105.     
  106.     
  107.     inStream->ReadData(&viewID, sizeof(ResIDT));
  108.     
  109.     InitPPobView(viewID);
  110. }
  111.  
  112.  
  113. // ---------------------------------------------------------------------------
  114. //        • ~LPPobView
  115. // ---------------------------------------------------------------------------
  116. //    Destructor
  117. //
  118.  
  119. LPPobView::~LPPobView()
  120. {
  121.     
  122. }
  123.  
  124.  
  125. // ---------------------------------------------------------------------------
  126. //        • InitPPobView
  127. // ---------------------------------------------------------------------------
  128.  
  129. void
  130. LPPobView::InitPPobView(
  131.     const ResIDT    inViewID)
  132. {
  133.     mViewID = inViewID;
  134.     
  135.     if(mViewID != -1) {
  136.         
  137.         SetDefaultView(mSuperView);
  138.         LView    *theView = (LView *) UReanimator::ReadObjects('PPob', mViewID);
  139.     }
  140. }
  141.  
  142.  
  143.